package com.android.webserver.tornado;

import com.android.webserver.WebServerService;

public class Tornado
{
	private final ServerPool					serverPool;
	private final ThreadManager				threadManager;

	/** Interface to the config file. */
	public final static Configuration	config	= new Configuration();
	/** Interface to the logging subsystem. */
	public final static Logger				log			= new Logger();
	/** Looks up the MIME type for a specified file extension. */
	// public final static MIMEDictionary mime;

	public static WebServerService		androidService;

	/**
	 * Constructs a server with the specified options. The server is prepared for
	 * production state, but it is fully started: we start
	 * <code>ServerThread</code>s, but don't bind to a local port. It is passed
	 * the command-line arguments specified, and it processes these.
	 * 
	 * @see #start()
	 */
	public Tornado(WebServerService service)
	{
		serverPool = new ServerPool(config.getStartThreads());
		threadManager = new ThreadManager(serverPool);
		androidService = service;
	}

	public void start()
	{
		Thread t = new ListenThread(serverPool, Tornado.config.getPort());
		t.start();
		System.out.println("Tornado is ready to accept connections");
		Thread tm = new Thread(threadManager);
		tm.start();
	}

	public void stop()
	{
	}
}
